// 存放首页的数据
$.get("https://www.easy-mock.com/mock/5a17dba3b23118413626a5d2/test/testing",
function (data) {
    console.log(data);
    //需要有现成的dom才能渲染进去
    const $te = [
        '<div class="banner-menu-item">',
        '</div>'
      ].join('');

      const $first = $(".banner-menu-item").eq(0);
      

      $(data.lis).each(function(index,element) {
        // console.log(index, element);
        const $index = index;
        $($te).clone().appendTo(".banner-menu-content");
        const $items = $(".banner-menu-item").not($first);
        const $item = $($items).get($index);
        // console.log($item);
        $(element.items).each(function (index, element) {
          // console.log(index, element);
          const $dlIndex = index;
          const $dl = '<dl></dl>';
          const $dt = '<dt></dt>';
          $($dl).clone().appendTo($item).addClass("clearfix")
          .end().append($dt).clone()
          .end().find("dt").text(element.bword)
          
          const $d = $($item).find("dl").get($dlIndex);
          const $dd = '<dd><a href=""></a></dd>';
          // console.log($d);
          $(element.btitle).each(function (index, element) {
            // console.log(index, element);
            $($d).append($dd).clone();
            const $ddIndex = index;
            const $a = $($d).find("dd").get($ddIndex);
            $($a).find("a").text(element.item)

          });

        });
      });
   //移动端随机生成图片
    
    // 创建模版
    const $fig = [
        '<figure class="swiper-slide">',
          '<a href="">',
            '<img src="" alt="">',
            '<figcaption><span></span></figcaption>',
          '</a>',
        '</figure>'
        ].join('');

        $(data.pimg).each(
          function(index, element) {
            // console.log(index, element);
            const $index = index;
            $($fig)
              .clone().appendTo(".mobile-like-picture .swiper-wrapper")
              .end().find("img").attr("src",element.item)
              .end().find("span").text(element.stitle+':'+element.sword)
          }
        );
    
        //pc端随机生成图片

        $(data.pimg).each(function(index, element){
          // console.log(index, element);
          const $index = index;
          $($fig)
            .clone().appendTo(".like-content-picture .swiper-wrapper")
            .end().find("img").attr("src",element.items)
            .end().find("span").text(element.stitle+':'+element.sword)
        });








    
    



},"json");


